package com.fy.springmvc.controller;

import com.fy.springmvc.enetity.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@CrossOrigin
public class HelloController {
    @RequestMapping("/hi.do")
    public String hi(@RequestParam("name") String username , Integer age, @DateTimeFormat(pattern = "yyyy/MM/dd") Date ctime){
        System.err.println("请求参数：" + username + "===>" +age+"..."+ctime.toString());
        return "hello";
    }

    @RequestMapping("/test1.do")
    public String  array(User user){
        System.err.println("Hello springMVC Test1");
        System.err.println(user);

        return "redirect:www.baidu.com";
    }


    //如果传递的参数是list 需要增加@RequestParam注解
    @RequestMapping("/li.do")
    public String  list(@RequestParam List<String> ids){
        System.err.println("Hello springMVC Test1");
        System.err.println(ids);
        return "/hello.html";
    }

//    @RequestMapping("/lll.do")
//    public String  lis(Vo l ){
//        System.err.println(l.getUsers());
//        return "/hello.html";
//    }

    @RequestMapping("/path/{id}")
    public String  pathParam(@PathVariable("id") String name){
        System.out.println(name);
        return "/hello.html";
}


}
